// JavaScript Document
 $('#login').on('click',function(){	
	 		 var msgError = $('#msg-error');
	 		 var otel = $("#login-tel"),
	 		 		opsd =  $("#login-psd");
	 		 var value1 ='',value2='';
		     var flag = true;
		     var tel = $("#login-tel").val();
		     var password = $("#login-psd").val();
		     var rule_tel = /^13[0-9]{1}[0-9]{8}|^18[0-9]{1}[0-9]{8}|^15[0-9]{1}[0-9]{8}|^17[0-9]{1}[0-9]{8}$/;
		     if(tel == null || tel == ""){
		    	 otel.addClass('val-error');
		    	 value1 = '请输入账号!';
		    	 //alert("请输入账号!");
		    	 flag = false;
		     }else if(!rule_tel.test(tel)){
		    	 otel.addClass('val-error');		    	
		    	 value1 = '请输入正确的手机号!';
		    	 //alert("请输入正确的手机号!");
		    	 flag = false;
		     }else if(password == null || password == ""){	    	
		    	 opsd.addClass('val-error');
		    	 value2 = '请输入密码!';
		    	 //alert("请输入密码!");
		    	 flag = false;
		     }
		     
		     if(rule_tel.test(tel)){
		 		otel.removeClass('val-error').addClass('val-success');
		 		value1='';
		 	}
		 	if(password == null || password == ""){
		 		opsd.removeClass('val-error').addClass('val-success');
		 		value2='';
		 	}
		     msgError.text('');
		     msgError.show().text(value1+ value2);
			 if(flag){
				 	msgError.hide();
				 	otel.removeClass('val-error');
				 	opsd.removeClass('val-error');
				 	otel.addClass('val-success');
				 	opsd.addClass('val-success');
					$.ajax({
				    	type:'post',
				    	url:"user/login",
				        data:{
				    		username:tel,
				    		password:password,
						},
				        success: function(result){
				        	$('#loading-box').hide();
				        	if(result.MSG != null && result.MSG != ""){
				        		msgError.show().text(result.MSG);
				    		}else{ 
				    			location.href="index/home";
				    		}
				         }
					});//ajax
		      	}//校验
		        	
		    });
